package ru.sviridov.sellandbuy;

import ru.sviridov.sellandbuy.model.query.QueryChangePassword;
import ru.sviridov.sellandbuy.tasks.base.BaseTask;
import ru.sviridov.sellandbuy.tasks.recipients.ChangePasswordRecipient;
import ru.sviridov.sellandbuy.tools.Utils;
import ru.sviridov.sellandbuy.url.APIGroup;
import ru.sviridov.sellandbuy.url.APIMethod;
import ru.sviridov.sellandbuy.url.URL;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class ChangePasswordActivity extends Activity{
	
	private BaseTask<Void> task;
	
	private EditText etNewPassword;
	private EditText etOldPassword;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ContentViewMapper.setContentView(this);
		
		etNewPassword = (EditText) findViewById(R.id.etNewPassword);
		etOldPassword = (EditText) findViewById(R.id.etOldPassword);
	}
	
	
	public void onClickChange(View view){
		QueryChangePassword queryParams = new QueryChangePassword();
		queryParams.setNewPassword(Utils.md5(etNewPassword.getText().toString()));
		queryParams.setOldPassword(Utils.md5(etOldPassword.getText().toString()));
		
		task = new BaseTask<Void>(this, new ChangePasswordRecipient());
		task.setQueryParams(queryParams);
		task.execute(URL.getURL(APIGroup.MEMBERSHIP, APIMethod.CHANGE_PASSWORD));
	}
}
